/*
 *  Copyright (c) 1998, Regents of the University of California
 *  All rights reserved.
 *  Redistribution and use in source and binary forms, with or without
 *  modification, are permitted provided that the following conditions are met:
 * 
 *      * Redistributions of source code must retain the above copyright
 *        notice, this list of conditions and the following disclaimer.
 *      * Redistributions in binary form must reproduce the above copyright
 *        notice, this list of conditions and the following disclaimer in the
 *        documentation and/or other materials provided with the distribution.
 *      * Neither the name of the University of California, Berkeley nor the
 *        names of its contributors may be used to endorse or promote products
 *        derived from this software without specific prior written permission.
 * 
 *  THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND ANY
 *  EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
 *  WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
 *  DISCLAIMED. IN NO EVENT SHALL THE REGENTS AND CONTRIBUTORS BE LIABLE FOR ANY
 *  DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
 *  (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
 *  LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
 *  ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
 *  (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
 *  SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 */

package org.demis.orc;

import java.sql.Types;

/**
 * @version 1.0
 * @author <a href="mailto:demis27@demis27.net">Stéphane kermabon</a>
 */
public class SQLTypeToClassConverter {

    public static String convert(int sqlType) {

        String javaType = null;

        switch (sqlType) {
            case Types.ARRAY:
                javaType = "unknown-ARRAY";
                break;

            case Types.BIGINT:
                javaType = "java.lang.Long";
                break;
            case Types.BINARY:
                javaType = "byte[]";
                break;
            case Types.BIT:
                javaType = "java.lang.Boolean";
                break;
            case Types.BLOB:
                javaType = "unknown-BLOB";
                break;
            case Types.BOOLEAN:
                javaType = "java.lang.Boolean";
                break;

            case Types.CHAR:
                javaType = "java.lang.String";
                break;
            case Types.CLOB:
                javaType = "unknown-CLOB";
                break;

            case Types.DATALINK:
                javaType = "unknown-DATALINK";
                break;
            case Types.DATE:
                javaType = "java.sql.Date";
                break;
            case Types.DECIMAL:
                javaType = "java.lang.Double";
                break;
            case Types.DISTINCT:
                javaType = "unknown-DISTINCT";
                break;
            case Types.DOUBLE:
                javaType = "java.lang.Double";
                break;

            case Types.FLOAT:
                javaType = "java.lang.Double";
                break;

            case Types.INTEGER:
                javaType = "java.lang.Integer";
                break;

            case Types.JAVA_OBJECT:
                javaType = "unknown-JAVA_OBJECT";
                break;

            case Types.LONGNVARCHAR:
                javaType = "unknown-LONGNVARCHAR";
                break;
            case Types.LONGVARBINARY:
                javaType = "unknown-LONGVARBINARY";
                break;
            case Types.LONGVARCHAR:
                javaType = "java.lang.String";
                break;

            case Types.NCHAR:
                javaType = "java.lang.String";
                break;
            case Types.NCLOB:
                javaType = "unknown-NCLOB";
                break;
            case Types.NUMERIC:
                javaType = "java.lang.Double";
                break;
            case Types.NVARCHAR:
                javaType = "java.lang.String";
                break;

            case Types.REAL:
                javaType = "java.lang.Float";
                break;
            case Types.REF:
                javaType = "unknown-REF";
                break;
            case Types.ROWID:
                javaType = "unknown-ROWID";
                break;

            case Types.SMALLINT:
                javaType = "java.lang.Short";
                break;
            case Types.SQLXML:
                javaType = "unknown-SQLXML";
                break;
            case Types.STRUCT:
                javaType = "unknown-STRUCT";
                break;

            case Types.TIME:
                javaType = "java.sql.Time";
                break;
            case Types.TIMESTAMP:
                javaType = "java.sql.Timestamp";
                break;
            case Types.TINYINT:
                javaType = "java.lang.Byte";
                break;

            case Types.VARBINARY:
                javaType = "unknown-VARBINARY";
                break;
            case Types.VARCHAR:
                javaType = "java.lang.String";
                break;
        }

        return javaType;
    }
}
